<template>
  <div>
    <el-button type="primary" @click="dialogFormVisible = true"
      >新增员工</el-button
    >

    <el-dialog title="员工信息" :visible.sync="dialogFormVisible">
      <el-form :model="form">
        <el-form-item label="员工账户" :label-width="formLabelWidth">
          <el-input v-model="form.username" autocomplete="off"></el-input>
        </el-form-item>
        
        <el-form-item label="项目组名" :label-width="formLabelWidth">
          <el-input v-model="form.usertype" autocomplete="off"></el-input>
        </el-form-item>

        <el-select v-model="value" placeholder="员工类型">
          <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>
        <div class="block"></div>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancel">取 消</el-button>
        <el-button type="primary" @click="add">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {mapActions} from "vuex"
export default {
  data() {
    return {
      dialogFormVisible: false,
      form: {
        username: "",
        usertype: "G1",
        region: "",
        date1: "",
        date2: "",
        delivery: false,
        type: [],
        resource: "",
        desc: "",
      },
      formLabelWidth: "120px",
      options: [
        {
          value: "2",
          label: "测试人员",
        },
        {
          value: "3",
          label: "开发人员",
        },
      ],
      value: "3",
    };
  },
  methods: {
    ...mapActions("managerInfo",["adduser"]),
    cancel() {
      this.dialogFormVisible = false;
      this.form.username = "";
      this.form.usertype = "G1";
      this.value = "3";
    },
    add() {
      let username=this.form.username;
      let usertype=this.form.usertype;
      let type=this.value;
      // console.log(username,usertype,type);
      let item={username,usertype,type};
      this.adduser(item).then((data)=>{
        this.$message(data.data.msg)
      })
      


      this.dialogFormVisible = false;
      this.form.username = "";
      this.form.usertype = "G1";
      this.value = "3";
    },
  },
};
</script>

<style>
</style>